<template>
  <div>
    <div class="Fg-space">
      <div class="Fg-margin">
        <div class="Fg-space-title">
          <span>外边距</span>
          <i class="el-icon-delete" @click="clearMargin"></i>
        </div>
        <input v-model="formValue.marginLeft" class="Fg-input-left" :disabled="disabled" />
        <input v-model="formValue.marginTop" class="Fg-input-top" :disabled="disabled" />
        <input v-model="formValue.marginRight" class="Fg-input-right" :disabled="disabled" />
        <input v-model="formValue.marginBottom" class="Fg-input-bottom" :disabled="disabled" />
      </div>
      <div class="Fg-padding">
        <div class="Fg-space-title">
          <span>内边距</span>
          <i class="el-icon-delete" @click="clearPadding"></i>
        </div>
        <input v-model="formValue.paddingLeft" class="Fg-input-left" :disabled="disabled" />
        <input v-model="formValue.paddingTop" class="Fg-input-top" :disabled="disabled" />
        <input v-model="formValue.paddingRight" class="Fg-input-right" :disabled="disabled" />
        <input v-model="formValue.paddingBottom" class="Fg-input-bottom" :disabled="disabled" />
      </div>
      <div class="Fg-wh">
        <!-- <div class="Fg-space-title">
          <span>宽x高</span>
          <i class="el-icon-delete" @click="clearWh"></i>
        </div>-->
        <input v-model="formValue.width" class="Fg-input-width" :disabled="disabled" />
        <span class="Fg-input-x">x</span>
        <input v-model="formValue.height" class="Fg-input-height" :disabled="disabled" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Object,
      default: () => {},
    },
    // 是否禁用
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      style: {},
      message: "",
    };
  },
  computed: {
    formValue: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
      },
    },
  },
  methods: {
    clearMargin() {
      if (this.disabled) return;
      this.formValue.marginLeft = "";
      this.formValue.marginTop = "";
      this.formValue.marginRight = "";
      this.formValue.marginBottom = "";
    },
    clearPadding() {
      if (this.disabled) return;
      this.formValue.paddingLeft = "";
      this.formValue.paddingTop = "";
      this.formValue.paddingRight = "";
      this.formValue.paddingBottom = "";
    },
    clearWh() {
      if (this.disabled) return;
      this.formValue.width = "";
      this.formValue.height = "";
    },
  },
  // watch: {
  //   formValue: {
  //     immediate: true,
  //     deep: true,
  //     handler(newValue) {

  //     },
  //   },
  // },
};
</script>


<style lang="scss" scoped>
.Fg-space {
  position: relative;
  height: 180px;
  font-size: 13px;
  .Fg-space-title {
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    i {
      cursor: pointer;
    }
  }
  input {
    background: transparent;
    border: none;
    border-bottom: 1px solid #000; /* 添加下划线 */
    outline: none; /* 移除聚焦时的默认轮廓 */
    width: 30px;
    margin: 0 5px;
    height: 20px;
    padding: 0;
    &:hover,
    &:active {
      background: #e8e9e3;
    }
  }
  .Fg-input-left,
  .Fg-input-top,
  .Fg-input-right,
  .Fg-input-bottom {
    position: absolute;
    z-index: 1;
  }
  .Fg-input-left {
    top: 50%;
    left: 0;
    transform: translateY(-10px);
  }
  .Fg-input-top {
    top: 5px;
    left: 50%;
    transform: translateX(-20px);
  }
  .Fg-input-right {
    top: 50%;
    right: 0;
    transform: translateY(-10px);
  }
  .Fg-input-bottom {
    bottom: 5px;
    left: 50%;
    transform: translateX(-20px);
  }
}
.Fg-margin {
  background-color: #f2cea5;
  position: absolute;
  inset: 0;
}
.Fg-padding {
  background-color: #c6cf92;
  position: absolute;
  inset: 30px 40px;
}
.Fg-wh {
  background-color: #94b5c0;
  position: absolute;
  inset: 60px 80px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>